package com.gj.service.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gj.dao.GoodDODao;
import com.gj.pojo.GoodDO;
import com.gj.pojo.GoodDOQuery;
import com.gj.service.GoodDOService;
import com.gj.utils.EasyUIDataGridResult;

@Service
public class GoodDOServiceImpl implements GoodDOService {
	
	@Autowired
	private SqlSession sqlSession;
	
	@Override
	public EasyUIDataGridResult getItemList(int page, int rows) {
		// 设置分页信息
				PageHelper.startPage(page, rows);
				// 执行查询
				GoodDOQuery example = new GoodDOQuery();
				GoodDODao goodDODao = sqlSession.getMapper(GoodDODao.class);
				List<GoodDO> list = goodDODao.selectByExample(example);
				// 取查询结果
				PageInfo<GoodDO> pageInfo = new PageInfo<>(list);
				EasyUIDataGridResult result = new EasyUIDataGridResult();
				result.setRows(list);
				result.setTotal(pageInfo.getTotal());
				// 返回结果
				return result;
	}

}
